var status = 0;
var choice;
var scrolls = [
    ["神秘之影手铳", 1492247, 10000],
    ["神秘之影斗拳", 1472277, 10000],
    ["神秘之影锤", 1322266, 10000],
    ["神秘之影魔法槌", 1252098, 10000],
    ["神秘之影能量剑", 1242122, 10000],
    ["神秘之影锤", 1322255, 10000],
    ["神秘之影能量剑", 1242121, 10000],
    ["神秘之影短枪", 1492235, 10000],
    ["神秘之影拳套", 1472265, 10000],
    ["神秘之影匕首", 1332279, 10000],
    ["神秘之影聚能锁链剑", 1242144, 10000],
    ["神秘之影聚能锁链剑", 1242145, 10000],
    ["神秘之影双手战斧", 1412181, 10000],
    ["神秘之影军刀", 1302359, 10000],
    ["神秘之影武器", 1690204, 10000],
    ["神秘之影双手战斧", 1412191, 10000],
    ["神秘之影短杖", 1372228, 10000],
    ["神秘之影单手剑", 1302343, 10000],
    ["神秘之影匕首", 1332291, 10000],
    ["神秘之影短杖", 1372239, 10000],
    ["神秘之影双手锤", 1422199, 10000],
    ["神秘之影长杖", 1382265, 10000],
    ["神秘之影双手锤", 1422189, 10000],
    ["神秘之影双手剑", 1402259, 10000],
    ["神秘之影刃", 1342110, 10000],
    ["神秘之影双手剑", 1402271, 10000],
    ["神秘之影刃", 1342104, 10000],
    ["神秘之影长枪", 1432218, 10000],
    ["神秘之影长杖", 1382276, 10000],
    ["神秘之影长枪", 1432229, 10000],
    ["神秘之影锁链", 1272017, 10000],
    ["神秘之影斧", 1312215, 10000],
    ["神秘之影ESP限制器", 1262039, 10000],
    ["神秘之影艾拉萨", 1582046, 10000],
    ["神秘之影手杖", 1362140, 10000],
    ["神秘之影双弩枪", 1522143, 10000],
    ["神秘之影双头杖", 1212120, 10000],
    ["神秘之影远古弓", 1592020, 10000],
    ["神秘之影斧", 1312203, 10000],
    ["神秘之影机甲枪", 1582023, 10000],
    ["神秘之影折扇 ", 1552119, 10000],
    ["神秘之影攻城炮", 1532150, 10000],
    ["神秘之影草扇", 1292018, 10000],
    ["神秘之影亡命剑", 1232113, 10000],
    ["神秘之影攻城炮", 1532159, 10000],
    ["神秘之影蛇吻", 1482234, 10000],
    ["神秘之影草扇", 1292030, 10000],
    ["神秘之影亡命剑", 1232124, 10000],
    ["神秘之影双头杖", 1212131, 10000],
    ["神秘之影武士刀", 1542117, 10000],
    ["神秘之影灵魂手铳", 1222113, 10000],
    ["神秘之影手杖", 1362151, 10000],
    ["神秘之影矛", 1442274, 10000],
    ["神秘之影弩", 1462243, 10000],
    ["神秘之影ESP限制器", 1262053, 10000],
    ["神秘之影弓", 1452257, 10000],
    ["神秘之影弩", 1462254, 10000],
    ["神秘之影锁链", 1272043, 10000],
    ["神秘之影矛", 1442287, 10000],
    ["神秘之影弓", 1452269, 10000],
    ["神秘之影指节", 1482221, 10000],
    ["神秘之影远古弓", 1592037, 10000],
    ["神秘之影双弩枪", 1522154, 10000],
    ["神秘之影灵魂手铳", 1222124, 10000],
    ["神秘之影", 1213018, 10000]
];

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(g, f, e) {
    if (g == -1) {
        cm.dispose()
    } else {
        if (status == 0 && g == 0) {
            cm.dispose();
            return
        } else {
            if (status >= 1 && g == 0) {
                cm.sendOk("好吧，欢迎下次继续光临！.");
                cm.dispose();
                return
            }
        }
        if (g == 1) {
            status++
        } else {
            status--
        }
        if (status == 0) {
            choices = "\r\n点卷：#r" + cm.getPlayer().getCSPoints(1) + "#k (#r买后不支持退货哟亲#k)";
            for (var b = 0; b < scrolls.length; b++) {
                choices += "\r\n#L" + b + "##v" + scrolls[b][1] + "##z" + scrolls[b][1] + "#　#d需要#r" + scrolls[b][2] + "#d点卷#k#l"
            }
            cm.askMenuS("欢迎来到" + cm.getServerName() + "专卖店,你想买我们商店的物品么?请选择吧：." + choices)
        } else {
            if (status == 1) {
                cm.askYesNo("你确定要购买#v" + scrolls[e][1] + "##t" + scrolls[e][1] + "#?");
                choice = e
            } else {
                if (status == 2) {
                    var d = scrolls[choice][2];
                    if (cm.getPlayer().getCSPoints(1) < d) {
                        cm.sendOk("抱歉，你没足够的点卷！");
                        cm.dispose()
                    } else {
                        var c = cm.getItemInfo();
                        var a = c.randomizeStats(c.getEquipById(scrolls[choice][1])).copy();
                        a.setStr(9999);
                        a.setDex(9999);
                        a.setInt(9999);
                        a.setLuk(9999);
                        a.setSpeed(99);
                        a.setJump(99);
                        a.setIuc(2);
                        a.setMaxDamageOver(9999950000000);
                        a.setOption(40603, 1, false);
                        a.setOption(40603, 2, false);
                        a.setOption(40603, 3, false);
                        a.setOption(40603, 1, true);
                        a.setOption(40603, 2, true);
                        a.setOption(40603, 3, true);
                        a.setEnhanceLevel(25);
                        a.setUpgradeLevel(15);
                        a.setUpgradeAvailable(0);
                        a.setBdr(99);
                        a.setImdr(99);
                        a.setDamR(99);
                        a.setStatR(99);
                        a.setTitle("神级");
                        cm.addFromDrop(cm.getClient(), a, false);
                        cm.gainItem(scrolls[choice][1], 1);
                        cm.getPlayer().modifyCSPoints(1, -d);
                        cm.dispose();
                        cm.sendOk("恭喜您成功购买#i" + scrolls[choice][1] + ":# #b#t" + scrolls[choice][1] + "##k。")
                    }
                }
            }
        }
    }
};